package com.inspur.security.cbb3.kms.keyusage.dataorders.po;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * DataorderBean
 *
 * @author liukai02
 * @date 2020/10/14
 */
@Entity
@Table(name = "tb_dataorders")
@Data

public class DataOrdersBean {

    /**
     * 主键
     */
    @Id
    @GenericGenerator(name = "idGenerator", strategy = "uuid")
    @GeneratedValue(generator = "idGenerator")
    private String uuid;

    /**
     * 生成时间
     */
    @Column
    private String createdTime;

    /**
     * 外部加密密钥
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String keyOutside;

    /**
     * 外部非对称密钥密码
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String keyPassword;

    /**
     * 内部加密密钥id
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String keyId;

    /**
     * 加密算法
     */
    @Column
    private String algorithm;

    /**
     * 数据操作类型: hash、encrypt、decrypt、sign、verify
     */
    @Column
    private String action;

    /**
     * 订单状态: pending、completed
     */
    @Column(name = "status" )
    private String status;

    /**
     * 订单处理报错错误码
     */
    @Column(name = "error_status_code" )
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String errorStatusCode;

    /**
     * 订单处理报错原因
     */
    @Column(name = "error_reason" )
    private String errorReason;

    /**
     * 数据订单生成用户id
     */
    @Column
    private String creatorId;

    /**
     * 数据id
     */
    @Column
    private String dataId;

    /**
     * 对称加密模式，cbc、ecb
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String encryptMode;

    /**
     * 对称加密填充模式，zeropadding, pkcs5padding
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String paddingMode;

    /**
     * 对称加密偏移量
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String iv;

    /**
     * 密文编码格式，base64、hex
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String outputEncoding;

    /**
     * 外部密钥内容编码格式，base64、hex
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String keyContentEncoding;

    /**
     * 签名hash算法
     */
    @Column
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String hashAlgorithm;

    /**
     * 返回数据下载接口，格式为/v1/data/{data_uuid}/resultdata
     */
    @Transient
    private String dataRef;

}
